import Vue from 'vue'
import VueRouter from 'vue-router'
import layout from '@/components/layout/index.vue'
Vue.use(VueRouter)
/**
 * title: 页面标题 
 * isLogin: 是否需要登录
 */
const routes = [
  { path: '/', redirect: '/findMusic' },
  {
    path: '/findMusic', name: 'findMusic', redirect: "/findMusic/recommend", component: layout, meta: { title: '发现音乐' },
    children: [
      { path: "recommend",  name: "findMusicRecommend",   component: () => import('@/views/recommend/index'), meta: { title: '推荐',transition:true } },
      { path: "ranking",    name: "findMusicRanking",     component: () => import('@/views/ranking/index'), meta: { title: '排行榜',transition:true } },
      { path: "songList",   name: "findMusicSongList",    component: () => import('@/views/songList/index'), meta: { title: '歌单',transition:true } },
      { path: "hostStation",name: "findMusicHostStation", component: () => import('@/views/hostStation/index'), meta: { title: '主播电台',transition:true } },
      { path: "singer",     name: "findMusicSinger",      component: () => import('@/views/singer/index'), meta: { title: '歌手',transition:true } },
      { path: "newDisc",    name: "findMusicNewDisc",     component: () => import('@/views/newDisc/index'), meta: { title: '新碟上架',transition:true } },

      { path: "singerDetails",    name: "singerDetails",     component: () => import('@/views/singerDetails/index'), meta: { title: '歌手详情',transition:true } },
      { path: "albumDetails",name:"albumDetails", component: () => import('@/views/albumDetails/index'), meta: { title: '专辑详情' } },
      { path: "albumList",name:"albumList", component: () => import('@/views/albumList/index'), meta: { title: '搜索结果' } },
      
    ]
  },
  {
    path: '/myMusic', name: 'myMusic', redirect: "/myMusic/index", component: layout, meta: { title: '我的音乐' },
    children: [
      { 
        path: "index", redirect:"/myMusic/authInfo", component: () => import('@/views/myMusic/index'), meta: { title: '我的音乐' },
        children:[
          { path: "/myMusic/authInfo", component: () => import('@/views/myMusic/authInfo'), meta: { title: '作者信息' } },
          { path: "/myMusic/systemSetting", component: () => import('@/views/myMusic/systemSetting'), meta: { title: '系统配置' } },
        ]
      }
    ]
  },
  {
    path: '/friend', name: 'friend', redirect: "/friend/index", component: layout, meta: { title: '朋友' },
    children: [
      { path: "index", component: () => import('@/views/friend/index'), meta: { title: '朋友' } }
    ]
  },
  // {
  //   path: '/shoping', name: 'shoping', redirect: "/shoping/index", component: layout, meta: { title: '商城' },
  //   children: [
  //     { path: "index", component: () => import('@/views/shoping/index'), meta: { title: '商城' } }
  //   ]
  // },
  // {
  //   path: '/musicPeople', name: 'musicPeople', redirect: "/musicPeople/index", component: layout, meta: { title: '音乐人' },
  //   children: [
  //     { path: "index", component: () => import('@/views/musicPeople/index'), meta: { title: '音乐人' } }
  //   ]
  // },
  {
    path: '/download', name: 'download', redirect: "/download/index", component: layout, meta: { title: '下载客户端' },
    children: [
      { path: "index", component: () => import('@/views/download/index'), meta: { title: '下载客户端' } }
    ]
  },
  // {
  //   path: '/authorArticle', name: 'authorArticle', redirect: "/authorArticle/index", component: layout, meta: { title: '创作者中心' },
  //   children: [
  //     { path: "index", component: () => import('@/views/authorArticle/index'), meta: { title: '创作者中心' } }
  //   ]
  // },
  // 登录后 个人信息 一类
  {
    path: '/myHomepage', name: 'myHomepage', redirect: "/myHomepage/index", component: layout, meta: { title: '我的主页' },
    children: [
      {
        path: "index", redirect:"/myHomepage/userpage", component: () => import('@/views/myHomepage/index'), meta: { title: '我的主页' },
        children:[
          { path: "/myHomepage/userpage", name:"userpage", component: () => import('@/views/myHomepage/userpage'), meta: { title: '我的主页',isLogin:true }, },
          { path: "/myHomepage/dynamic", name:"dynamic", component: () => import('@/views/myHomepage/dynamic'), meta: { title: '动态',isLogin:true },},
          { path: "/myHomepage/attention", name:"attention", component: () => import('@/views/myHomepage/attention'), meta: { title: '关注',isLogin:true }, },
          { path: "/myHomepage/fans", name:"fans", component: () => import('@/views/myHomepage/fans'), meta: { title: '粉丝',isLogin:true }, },
        ]
      }
    ]
  },
  {
    path: '/myMessage', name: 'myMessage', redirect: "/myMessage/index", component: layout, meta: { title: '我的消息' },
    children: [
      { 
        path: "index", redirect:"/myMessage/mymsg", component: () => import('@/views/myMessage/index'), meta: { title: '我的消息',isLogin:true },
        children:[
          { path: "/myMessage/mymsg", component: () => import('@/views/myMessage/mymsg'), meta: { title: '@我的',isLogin:true } },
          { path: "/myMessage/privateLetter", component: () => import('@/views/myMessage/privateLetter'), meta: { title: '私信',isLogin:true } },
          { path: "/myMessage/comment", component: () => import('@/views/myMessage/comment'), meta: { title: '评论',isLogin:true } },
          { path: "/myMessage/inform", component: () => import('@/views/myMessage/inform'), meta: { title: '通知',isLogin:true } },
        ] 
      },
    ]
  },
  {
    path: '/myGrades', name: 'myGrades', redirect: "/myGrades/index", component: layout, meta: { title: '我的等级' },
    children: [
      { path: "index", component: () => import('@/views/myGrades/index'), meta: { title: '我的等级',isLogin:true } },
      { path: "info", component: () => import('@/views/myGrades/info'), meta: { title: '等级特权' } }
    ]
  },
  {
    path: '/vipMember', name: 'vipMember', redirect: "/vipMember/index", component: layout, meta: { title: 'VIP会员' },
    children: [
      { path: "index", component: () => import('@/views/vipMember/index'), meta: { title: 'VIP会员' } }
    ]
  },
  {
    path: '/personalSetting', name: 'personalSetting', redirect: "/personalSetting/index", component: layout, meta: { title: '个人设置' },
    children: [
      {
        path: "index", redirect:"/personalSetting/personal", component: () => import('@/views/personalSetting/index'), meta: { title: '个人设置' },
        children:[
          { path: "/personalSetting/personal", component: () => import('@/views/personalSetting/personal'), meta: { title: '个人设置',isLogin:true }, },
          { path: "/personalSetting/binding", component: () => import('@/views/personalSetting/binding'), meta: { title: '绑定设置',isLogin:true }, },
          { path: "/personalSetting/privacy", component: () => import('@/views/personalSetting/privacy'), meta: { title: '隐私设置',isLogin:true }, }
        ]
      }
    ]
  },
  {
    path: '/replacePicture', name: 'replacePicture', redirect: "/replacePicture/index", component: layout, meta: { title: '更换头像' },
    children: [
      { path: "index", component: () => import('@/views/replacePicture/index'), meta: { title: '更换头像',isLogin:true } }
    ]
  },
  
  // 404
  { path: '/404', name: '404', component: () => import('@/views/404'), meta: { title: '找不到页面啦' } },
  { path: '*', redirect: '/404' },
]
const scrollBehavior = function (to, from, savedPosition) {
  if (savedPosition) {
    return savedPosition
  } else {
    return { x: 0, y: 0 }
  }
}
const router = new VueRouter({
  scrollBehavior,
  routes
})

export default router
